import component from "../../../common/component";
import {Button, Col, Input,Row} from "antd";
import DelBtn from "@/components/DelBtn"


class equscrap extends component {
     //右上角 新建设备类型与删除选中 按钮
   
    //搜索栏  搜索栏不可指定搜索属性搜索
    getSearchRow(): null {
        return <Input.Group>
            <Row gutter={8}>
                <Col span={6}>
                    <Input onChange={this.handleChange} allowClear placeholder="设备编号" onPressEnter={this.reload}
                           name={'equCode'}/>
                </Col>
                <Col span={6}>
                    <Input onChange={this.handleChange} allowClear placeholder="设备名称" onPressEnter={this.reload}
                           name={'name'}/>
                </Col>
                <Col span={3}>
                    <Button type={'primary'} onClick={this.reload}>搜索</Button>
                </Col>
            </Row>
        </Input.Group>;
    }
    //主体部分页眉
    getColumns(): null {
        return [
            {
                title: '设备编号',
                dataIndex: 'equCode',
                key: 'equCode',
            },
            {
                title: '设备名称',
                dataIndex: 'name',
                key: 'name',
            },
            {
                title: '报废时间',
                dataIndex: 'scrapTime',
                key: 'scrapTime',
                sorter: (a, b) => {
                    // 将日期转成毫秒
                      const t1 = new Date(a.scrapTime).getTime();
                      const t2 = new Date(b.scrapTime).getTime();
                      return t1- t2
                    },
                    sortDirections: ['descend', 'ascend'],
                    defaultSortOrder: 'descend'
            },
            {
                title: '操作',
                dataIndex: 'operation',
                fixed: 'right',
                render: (_, record) => {
                    return <DelBtn record={record} del={this.delete}/>
                },
            }
        ];
    }

}

export default equscrap;
